// pages/my/pojectlist/pojectlist.js
const app=getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageNo:1,
    pageSize:10,
    datalist:[],
    isnodatalist:false,
    loadlist:false,
    nomorelist:false,
    
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log('opss',options)
    this.setData({
      title:options.title,
      type:options.type,
      identity:options.identity,
      userid:options.userid,
      Imageurl:app.globalData.Imageurl,
      scrooltop:app.globalData.maskheight,
    })
   this.getProjectCollectDetailsPage()
  },

  getProjectCollectDetailsPage() {
    
    let that = this
    if (that.data.pageNo!=1) {
      that.setData({
        loadlist:true
      })
    }
   
    wx.request({
      url: app.globalData.Interfaceurl + "getProjectCollectDetailsPage",
      method: 'POST',
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=UTF-8"
      },
      data: {
        userId: that.data.userid,
        pageNo: that.data.pageNo,
        pageSize: that.data.pageSize,
        selectField:that.data.type
      },
      success(res) {
        console.log(res)
        console.log(that.data.datalist=='')
        if (that.data.pageNo==1) {
          that.setData({
            num:res.data.number,
            amount:res.data.amount
          })
        }
          that.setData({
            datalist: that.data.datalist.concat(res.data.page.list),
            toalpages: Math.ceil(res.data.page.count / that.data.pageSize),
            loadlist:false
            // toalpages:5
          })
        
          if (that.data.datalist.length==0) {
            that.setData({
              isnodatalist:true
            })
          }else{
            if (that.data.toalpages==that.data.pageNo) {
              that.setData({
                nomorelist:true
              })
            }else{
              that.setData({
                nomorelist:false
              })
            }
          }
       
       
        
      }
    })
  },
  godtail(e) {
    let orderId = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/projectDetails/projectDetails?orderId=' + orderId,
    })
  },


  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {
    if (this.data.toalpages>this.data.pageNo) {
      this.data.pageNo++
      this.getProjectCollectDetailsPage()
    }
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})